import 'package:flutter/material.dart';

class ReportDialogContent extends StatefulWidget {
  ReportDialogContent({Key key, this.reports,this.selected}) :super(key: key);
  final List<String> reports;
  final List<String> selected;

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new _ReportDialogContentState();
  }
}

class _ReportDialogContentState extends State<ReportDialogContent> {
  @override
  Widget build(BuildContext context) {
    final List<Widget> reportChips = widget.reports.map<Widget>((String name) {
      return new FilterChip(
        key: new ValueKey<String>(name),
        label: new Text(name),
        selectedColor: Colors.lightBlue,
        selected: widget.selected.contains(name),
        onSelected: (bool value) {
          if (value) {
            setState(() {
              widget.selected.add(name);
            });
          } else {
            setState(() {
              widget.selected.remove(name);
            });
          }
        },
      );
    }).toList();

    // TODO: implement build
    return new Container(
      margin: const EdgeInsets.only(top: 15.0, right: 5.0, left: 5.0),
      child: new Wrap(
        children: reportChips.map((Widget chip) =>
        new Padding(
          padding: const EdgeInsets.all(6.0),
          child: chip,
        )).toList(),
      ),
    );
  }
}